#include "std_lib.h"

int main(int argc, char* argv[])
{
	cout<<"Please enter expression (we can handle +,-,*, and /)\n";
	cout<<"add an x to end expression (e.g.,1+2*3;):";
	int lval = 0;
	int rval;
	char op;
	cin>>lval;
	if (!cin) error("no first operand");
	while (cin>>op) {
		if (op!=';') cin>>rval;
		if (!cin) error("no second operand");
		switch (op) {
		case '+':
			lval += rval;
			break;
		case '-':
			lval -= rval;
			break;
		case '*':
			lval *= rval;
			break;
		case '/':
			lval /= rval;
			break;
		default:
			cout<<"Result: "<<lval<<'\n';
			keep_window();
			return 0;
		}
	}
	error("bad expression");
}